﻿using System.Windows.Media;
using System.Windows.Shapes;
using System.Collections.Generic;

namespace MyFloridaHouse.libSvBingMapsMultiShape
{
    public class MapMultiPolyline : MapMultiShapeBase
    {
        private IList<PointCollection> _projectedPoints;

        // Methods
        public MapMultiPolyline()
            : base(new Path())
        {
        }

        public override IList<PointCollection> ProjectedPoints
        {
            get
            {
                return _projectedPoints;
            }
            set
            {
                _projectedPoints = value;

                if (_projectedPoints != null)
                {
                    PathGeometry polylines = new PathGeometry();

                    foreach(PointCollection pc in _projectedPoints) //loop through each ring
                    {
                        PolyLineSegment poly = new PolyLineSegment();
                        poly.Points = pc;

                        PathFigure fig = new PathFigure();
                        fig.StartPoint = pc[0];
                        fig.Segments.Add(poly);

                        polylines.Figures.Add(fig);
                    }

                    //update Path
                    ((Path)base.EncapsulatedShape).Data = polylines;
                }
            }
        }
    }
}
